package com.example.ele_guarantee_hh_pro.trigger;

import com.cloudcc.deveditor.trigger.TriggerEditor;
import com.cloudcc.deveditor.core.CCObject;
import com.cloudcc.deveditor.trigger.TriggerEditor;

import java.util.List;

/*投标频率*/
public class ele_num extends TriggerEditor {

    public void beforeUpdate(){
        String userId = userInfo.getUserId();
        //管户区域
        String fk_psmc = record_new.get("fk_psmc")==null?"":record_new.get("fk_psmc")+"";
        String name="";
        List<CCObject> psmc = this.cquery("psmc", "id='" + fk_psmc + "'");
        if(psmc.size()>0){
            name=psmc.get(0).get("name")==null?"":psmc.get(0).get("name")+"";
        }
        String sql = "select * from ghjl where " +
                "yh='"+userId+"' " +
                "and jyzx='"+fk_psmc+"' " +
                "and is_deleted='0'";
        List<CCObject> ghjl_list = this.cqlQuery("ghjl", sql);
        if (ghjl_list.size()==0){
            if (true)trigger.addErrorMessage("你没有"+name+"的管户权限，无法修改该投标频次！");
        }
    }
}
